<br/>
<% def date = new Date().format('dd-MM-yyyy') %>
<div>
	<b>From* </b>
	&nbsp;&nbsp;
	<input type="text" id="fromDate" name="fromDate" value="" size="7"/>
	&nbsp;[YYYY-MM-DD]
	&nbsp;&nbsp;
	<b>Time* &nbsp;&nbsp;</b>
	<input type="text" name="fromTime" value="00:00" size="4" id="fromTime"/>
	&nbsp;[HH:mm]
	&nbsp;&nbsp;
	<b>To* </b>
	&nbsp;&nbsp;
	<input type="text" id="toDate" name="toDate" value="${date}" size="7"/>
	&nbsp;[YYYY-MM-DD]
	&nbsp;&nbsp;
	<b>Time &nbsp;&nbsp;</b>
	<input type="text" name="toTime" value="23:59" size="4" id="toTime"/>
	&nbsp;[HH:mm]
	&nbsp;&nbsp;
	<input type="button" value="Go" onClick="transcationViewAll()"/> 
</div>
<div id="viewAllResults"></div>
<script type="text/javascript">
\$(document).ready(function() {
	\$('#fromTime').timepicker({});
	\$('#toTime').timepicker({});
	\$("input:button").button();
});

\$(function() {
	var dates = \$( "#fromDate, #toDate" ).datepicker({
		dateFormat : "dd-mm-yy",
		maxDate    : 0,
		onSelect   : function( selectedDate ) {
			var option = this.id == "fromDate" ? "minDate" : "maxDate", instance = \$( this ).data( "datepicker" ),
			date = \$.datepicker.parseDate(instance.settings.dateFormat ||  \$.datepicker._defaults.dateFormat, selectedDate , instance.settings );
			dates.not( this ).datepicker( "option", option, date );
		}
	});
});

function transcationViewAll() {
	var fromDate = \$('#fromDate').val();
	var fromTime = \$('#fromTime').val();
	var toDate = \$('#toDate').val();
	var toTime = \$('#toTime').val();
	if(fromDate == '') {
		alert('Select from date');
		\$('#fromDate').focus();
		return;
	}
	\$.post('transcationSearch.groovy',
			{	
				fromDate : fromDate, 
				fromTime : fromTime, 
				toDate   : toDate, 
				toTime   : toTime 
			},
			function(data) {
				\$('#viewAllResults').replaceWith(data);
				/*
				\$('#fromDate').val('');
				\$('#fromTime').val('00:00');
				var now = new Date();
				var s = now.getFullYear() + "-";
				if(now.getMonth() < 9) {
					s += "0";
				}
				s += now.getMonth() + 1 + "-";
				if(now.getDate() < 10) {
					s += "0";
				}
				s += now.getDate();
				\$('#toDate').val(s);
				\$('#toTime').val('23:59');
				*/
		 	}
		);
};
</script>